package bpm.dao.impl.deptagenda;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import bpm.domain.deptagenda.AgendaDept;
import bpm.domain.deptagenda.AgendaUser;
import bpm.domain.deptagenda.AgendaUserRelaiton;
/**
 * 
 * @author wanglong635@126.com
 *
 */
public class AgendaUserRelationMapper implements RowMapper {

	public Object mapRow(ResultSet rs, int i) throws SQLException {
		AgendaUserRelaiton relation = new AgendaUserRelaiton();
		relation.id = rs.getString("ID");
		relation.agendaId = rs.getString("AGENDAID");
		
		AgendaUser leader = new AgendaUser();
		leader.setUserId(rs.getString("USERID"));
		leader.setUserName(rs.getString("USERNAME"));
		leader.setUserMain(rs.getString("USERMAIN"));

		
		AgendaDept dept = new AgendaDept();
		dept.setDeptCode(rs.getString("DEPTCODE"));
		dept.setDeptName(rs.getString("DEPTNAME"));
		dept.setDeptIndex(rs.getString("INDEX").split("_")[2]);
		String [] a=rs.getString("INDEX").split("_");
		AgendaDept pdept = new AgendaDept();
		pdept.setDeptCode(rs.getString("DEPTPCODE"));
		pdept.setDeptName(rs.getString("DEPTPNAME"));
		pdept.setDeptIndex(rs.getString("INDEX").split("_")[1]);
		dept.setDeptParent(pdept);
		
		leader.setAgendaDept(dept);
		relation.leader = leader;
		relation.index = rs.getString("INDEX");
		
		return relation;
	}

}
